package com.jishuo.nontax.bfc.service;


import com.jishuo.base.config.NonTaxConfig;
import com.jishuo.nontax.bean.vo.BankVO;
import com.jishuo.nontax.bfc.dao.*;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Repository
public class TaskService {

    @Resource
    private BankCheckBillMapper bankCheckBillMapper;
    @Resource
    private BankBalanceMapper bankBalanceMapper;
    @Resource
    private BankCheckMapper bankCheckMapper;
    @Resource
    private BankMapper bankMapper;
    @Resource
    private BankBalanceService bankBalanceService;
    @Resource
    @Lazy
    private BankCheckBillService bankCheckBillService;
    @Resource
    private WaitaffirmService waitaffirmService;
    @Resource
    private WaitaffirmPayInfoService waitaffirmPayInfoService;
    @Resource
    private DeductService deductService;
    @Resource
    private PreerrMapper preerrMapper;
    @Resource
    private NonTaxConfig nonTaxConfig;
    @Resource
    private EpayFiscService epayFiscService;
    @Resource
    private EpayFiscMapper epayFiscMapper;


    public void autocheck() {
        try {
            List<BankVO> list =findBank(nonTaxConfig.Checkcantonid,nonTaxConfig.Sender);
            Calendar c = Calendar.getInstance();
            c.setTime(new Date());
            c.set(Calendar.DATE, c.get(Calendar.DATE)-1);
            String paybankdt = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
            c=null;
            epayFiscService.dealEpayFisc(0, paybankdt);
//            for(BankVO bank:list){
//                Long bankid = bank.getBankid();
                checkData(176, paybankdt);
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public List<BankVO> findBank(String cantonid,String bankcls){
        if("close".equals(cantonid)){
            return new ArrayList<BankVO>();
        }else if(cantonid!=null && !cantonid.trim().equals("") && cantonid.trim().equals("all")) {
            return bankMapper.bankclasFindBankVo(bankcls);
        }else if(cantonid!=null && !cantonid.trim().equals("") && !cantonid.trim().equals("all")){
            String[] str = cantonid.split("&&");
            return bankMapper.canOneTwoBankVo(bankcls,str[0],str[1]);
        }else{
            return new ArrayList<BankVO>();
        }
    }

    public void checkData(long bankid,String paybankdt){}


}
